using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;

/// <summary>
/// Summary description for GlobalClass
/// </summary>
public class GlobalClassFE : CommonClass
{
    #region Language
    public static string CurrentLanguage
    {
        get
        {
            if (HttpContext.Current.Session["ssLanguage"] != null)
                return HttpContext.Current.Session["ssLanguage"].ToString();
            return "";
        }
        set
        {
            if (HttpContext.Current.Session["ssLanguage"] != null)
                HttpContext.Current.Session.Remove("ssLanguage");
            HttpContext.Current.Session.Add("ssLanguage", value);
        }
    }
    public static string CurrentLanguageCode
    {
        get
        {
            if (HttpContext.Current.Session["ssLanguageCode"] != null)
                return HttpContext.Current.Session["ssLanguageCode"].ToString();
            return "";
        }
        set
        {
            if (HttpContext.Current.Session["ssLanguageCode"] != null)
                HttpContext.Current.Session.Remove("ssLanguageCode");
            HttpContext.Current.Session.Add("ssLanguageCode", value);
        }
    }
    #endregion Language
    #region show content static page

    public static void ShowStaticContent(Table pTable, string pIDPages)
    {
        DataTable dt = getContent(pIDPages);
        //if (dt != null && dt.Rows.Count > 0)
        //{
        //    GssDO.DOPage pageDO = new GssDO.DOPage();
        //    string s = dt.Rows[0][pageDO.ContentColumnName + CurrentLanguage].ToString();
        //    if (s.Trim() != "")
        //    {
        //        TableCell cell = new TableCell();
        //        cell.Controls.Add(new LiteralControl(s));
        //        cell.CssClass = "content";
        //        TableRow row = new TableRow();
        //        row.Cells.Add(cell);
        //        pTable.Rows.Add(row);
        //    }
        //}
    }

    private static DataTable getContent(string pIDPages)
    {
        DataTable dt = null;
        //try
        //{
        //    GssDO.DOPage pageDO = new GssDO.DOPage();
        //    IDictionary iDic = GssDAOBase.GssQueryBuilder.CreateCollection();
        //    iDic.Add(pageDO.PKIDPageColumnName, pIDPages);
        //    GssBL.BLPage objPage = new GssBL.BLPage();
        //    dt = objPage.SelectData(iDic);
        //}
        //catch (Exception exc)
        //{
        //    string mess = exc.Message.ToString();
        //    dt = null;
        //}
        return dt;
    }

    public static string GetContentType(string pFileExt)
    {
        if (pFileExt == ".asf")
            return "video/x-ms-asf";
        if (pFileExt == ".avi")
            return "video/avi";
        if (pFileExt == ".doc")
            return "application/msword";
        if (pFileExt == ".zip")
            return "application/zip";
        if (pFileExt == ".xls")
            return "application/vnd.ms-excel";
        if (pFileExt == ".gif")
            return "image/gif";
        if (pFileExt == ".jpg")
            return "image/jpeg";
        if (pFileExt == ".wav")
            return "audio/wav";
        if (pFileExt == ".mp3")
            return "audio/mpeg3";
        if (pFileExt == ".mpg" || pFileExt == ".mpeg")
            return "video/mpeg";
        if (pFileExt == ".rtf")
            return "application/rtf";
        if (pFileExt == ".htm" || pFileExt == ".html")
            return "text/html";
        if (pFileExt == ".asp")
            return "text/asp";
        return "application/octet-stream";
    }

    #endregion
}
